package com.trendytech.tds.entity;

/**
 * 操作日志
 * @author Robin
 *
 */
public class OperationLog extends AbstractEntity {

	private static final long serialVersionUID = -7122229931006148752L;
	
	public OperationLog() { }
	public OperationLog(String userId, String resourceId) {
		this.userId = userId;
		this.resourceId = resourceId;
	}
	
	public enum Type {
		SELECT,
		INSERT,
		UPDATE,
		DELETE
	}

	private String userId;

    private String description;

    private Integer type;

    private String resourceId;
    
    private String username;
    
    private String ip; //bieyd
    
    private int result; //0:fail 1:success
    
    private int dangerLevel;
    
    public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getDescription() {
        return description;
    }
    
    public String getIp() { //bieyd
        return ip;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getResourceId() {
        return resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }
    
    public void setIp(String ip){
    	this.ip=ip;
    }
	public int getResult() {
		return result;
	}
	public void setResult(int result) {
		this.result = result;
	}
	public int getDangerLevel() {
		return dangerLevel;
	}
	public void setDangerLevel(int dangerLevel) {
		this.dangerLevel = dangerLevel;
	}
	@Override
	public String toString() {
		return "OperationLog [userId=" + userId + ", description=" + description + ", type=" + type + ", resourceId="
				+ resourceId + ", username=" + username + ", ip=" + ip + ", result=" + result + ", dangerLevel="
				+ dangerLevel + "]";
	}
	
	public String formatResult(){
		if(this.result == 1){
			return "Success";
		}else{
			return "Fail";
		}
	}
	
	public String formatDangerLevel(){
		if(this.dangerLevel == 1){
			return "Low";
		}else if(this.dangerLevel == 2){
			return "Middle";
		}else{
			return "High";
		}
	}
}